#include "Texture.h"


Texture::Texture(const char* fd, int tID, float ls, float lt, int type){
	if(type==0){
		texID=tID;
		setLengthT(lt);
		setLengthS(ls);

		RGBpixmap * pixmap = new RGBpixmap();
		pixmap->readBMPFile(fd);
		//if(!(pixmap->readBMPFile(fd)))
			//exit(1);
		pixmap->setTexture(getTexID());
	//printf("tex created with lt:%f ls%f and tID:%d",getLengthS(),getLengthT(),getTexID());//DEBUG
	}

	
	none=inheritTex=false;
	if(type==1)
		inheritTex=true;
	else if(type==2)
		none=true;
}

int Texture::getTexID(){
	
	return texID;
}

float Texture::getLengthS()
{
	return length_s;
}

float Texture::getLengthT()
{
	return length_t;
}

void Texture::setLengthT( float lt )
{
	this->length_t=lt;
}

void Texture::setLengthS( float ls )
{
	this->length_s=ls;
}

void Texture::act()
{
	if(none){
		glBindTexture(GL_TEXTURE_2D,0);
		glDisable(GL_TEXTURE_2D);
	}
	else
		glEnable(GL_TEXTURE_2D);

	if(!inheritTex)
		glBindTexture(GL_TEXTURE_2D,getTexID());
}
